﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;

// 伤害管理器
public class DamageMgr : Singleton<DamageMgr>
{
    // 物理性伤害 攻击力-防御力 最小值取0或1
    public int PhysicsDamage(Creature attacker, Creature defencer, CreatureSkill skillObj)
    {
        // 伤害公式
        var skillAttack = attacker.ServerData.Attack + skillObj.Data.Damage;

        // 最小伤害1点血
        var damage = Mathf.Max(skillAttack - defencer.ServerData.Defence, 1);

        // 修改血量
        defencer.HP -= damage;

        return damage;
    }

    // 对多个目标同时造成伤害
    public void PhysicsDamage(Creature attacker, List<Creature> hitList, CreatureSkill skillObj)
    {
        foreach (var creature in hitList)
        {
            PhysicsDamage(attacker, creature, skillObj);
        }
    }

    // 法术性伤害 法术强度 - 法术防御 最小值取0或1
}

